# !/usr/bin/env python
# -*- coding: utf-8 -*-
# Created by master on 2017/3/9


import threading
import time


def run(n):
    print("[%s]----------running----------\n" % n)
    time.sleep(2)
    print("------done----")


t_list = []


def main():
    for i in range(5):
        t = threading.Thread(target=run, args=[i, ])

        t.start()
        t_list.append(t)
        print("starting thread", t.getName())

    for i in t_list:
        i.join()


m = threading.Thread(target=main, args=[])
# m.setDaemon(True)  # 守护线程结束后 所有被他守护的线程都会被干掉
m.start()
m.join(timeout=2)  # 设置超时时间

print("-----main  thread done----")
